package com.peng.test.regex;

import java.util.regex.Pattern;

import org.junit.Test;

/**
 * Regex1
 * <p>
 * Created on 2022/10/23
 *
 * @author lupeng
 */
public class Regex1 {

    @Test
    public void t1() {
        Pattern p = Pattern.compile("^[0-9|,]*$");
        String s = "12312381,182739172,18273172 ";
        System.out.println(p.matcher(s).find());
    }

    @Test
    public void t2() {
        String sql = "asdfasf";
        System.out.println(sql.substring(0, sql.length() - 1));
    }
    @Test
    public void t3() {
        System.out.println(formatGiftScore(25466611));
        System.out.println(formatGiftScore(2166661));
        System.out.println(formatGiftScore(256666));
        System.out.println(formatGiftScore(21666));
        System.out.println(formatGiftScore(2126));
        System.out.println(formatGiftScore(212));
    }

    private static long formatGiftScore(long score) {
        if (score > 1000000) {
            return Math.round(score / 100000.0) * 100000;
        }
        if (score > 100000) {
            return Math.round(score / 10000.0) * 10000;
        }
        if (score > 10000) {
            return Math.round(score / 1000.0) * 1000;
        }
        if (score > 1000) {
            return Math.round(score / 100.0) * 100;
        }
        if (score > 100) {
            return Math.round(score / 10.0) * 10;
        }
        return score;
    }
}
